<!--{__NOLAYOUT__}-->
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="__STATIC__/js/layui/css/layui.css">
</head>
<body>

    <div style="margin: 5px;">
        <table id="comment-table" lay-filter="comment-table-filter"></table>
    </div>

    <script type="text/html" id="commentBar">
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    </script>

    <script src="__STATIC__/js/layui/layui.js" charset="utf-8"></script>
<script>
    layui.use('table', function () {
        var table = layui.table;
        var $ = layui.$;
        //-------留言管理表格s--------
        var comment = table.render({
            elem: '#comment-table'
            , height: 'full'
            , url: '/admin/article/comment?articid='+{$articid}
            , page: true
            , cols: [[
                {field: 'commentid', title: 'ID'}
                , {field: 'userid', title: '用户账号'}
                , {field: 'content', title: '评论内容'}
                , {field: '', title: '操作', toolbar: '#commentBar'}
            ]]
        });
        table.on('tool(comment-table-filter)', function (obj) {
            var data = obj.data;
            if (obj.event == 'del') {
                layer.confirm('是否要删除' + data.userid + '的这条评论', function (index) {
                    $.ajax({
                        type: 'post'
                        , url: '/admin/article/commentdell'
                        , dataType: 'json'
                        , data: {commentid: data.commentid}
                        , success: function (obj1) {
                            if (obj1.code == 1) {
                                obj.del();
                            }
                            layer.alert(obj1.msg);
                        }
                    });
                    layer.close(index);
                });
            }
        });
        //-------留言管理表格e--------
    });

</script>


</body>
</html>